package com.basin.micro.uplaod.controller;

import com.basin.common.core.response.ResponseResult;
import com.basin.micro.uplaod.service.UploadService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
@Slf4j
@RestController
@RequestMapping("/")
@RequiredArgsConstructor
public class UploadController {
    private final UploadService uploadService;

    @PostMapping("/upload-file")
    public ResponseResult<List<String>> uploadFile(@RequestParam("file") MultipartFile[] files) {
        List<String> urls = uploadService.upload(files);
        return ResponseResult.success(urls);
    }
}
